' This software is a port of Mike Dogan's great ParticleCandy for BlitzBasic3d
'
' http://www.x-pressive.com
'
' Check his page if you're interested in his latest ParticleCandy Engine
' for Corona SDK!
'
' A BIG THANKS goes to him as he gave the permission to publish this as open source
'
' For any support or questions contact: martin.leidel@gmail.com
'
' This software is provided 'as-is', without any express or implied
' warranty.  In no event will the authors be held liable for any damages
' arising from the use of this software.
' 
' Permission is granted to anyone to use this software for any purpose,
' including commercial applications, and to alter it and redistribute it
' freely, subject to the following restrictions:
' 
' 1. The origin of this software must not be misrepresented; you must not
' claim that you wrote the original software. If you use this software
' in a product, an acknowledgment in the product documentation would be
' appreciated but is not required.
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
' 3. This notice may not be removed or altered from any source distribution.

Import particlecandy

' ------------------------------------
' CHANGE THIS WHEN USING THIS LIBRARY:
'TODO Global soundPath:String = cdir +"media\" '"
' ------------------------------------

Function CreateEmitter_Test:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int

  EM = pc.createEmitter()

  ' SIMPLE TEST PARTICLES
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 8 )
  pc.setPTSpeed( P1, 7 )
  pc.setPTSize( P1, 0.25 )
  pc.setPTAlpha( P1, 1 )
  pc.setPTWeight( P1, 0.5 )
  pc.setPTRotation( P1, 0, 0 )
  pc.setPTColor( P1, 240, 240, 240, 40, -50, -50, -50 )
  pc.setPTEmissionAngle( P1, 0, 90 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 4000 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTAddedBlend( P1, 0 )

  EM.addParticleType( P1, 0, 99000, 985 )
  Return EM
End Function

Function CreateEmitter_WaterFontain:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int

  EM = pc.createEmitter()

  ' MIST
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 2 )
  pc.setPTSpeed( P1, 15, 2 )
  pc.setPTSize( P1, 0.75, 0.75, 3, 3 )
  pc.setPTAlpha( P1, 1, 0.5, -1 )
  pc.setPTWeight( P1, 3, 0.5 )
  pc.setPTRotation( P1, 2, 0 )
  pc.setPTColor( P1, 225, 225, 255, 40, -125, -125, -100 )
  pc.setPTEmissionAngle( P1, 0, 15 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 3000 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTAddedBlend( P1, 0 )

  ' BUBBLES
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 3 )
  pc.setPTSpeed( P2, 5, 2 )
  pc.setPTSize( P2, 0.7, 0.5 )
  pc.setPTAlpha( P2, 1, 0.5, -1 )
  pc.setPTWeight( P2, 3, 0.5 )
  pc.setPTRotation( P2, 1, 0 )
  pc.setPTColor( P2, 210, 210, 255, 20, -100, -100, -75 )
  pc.setPTEmissionAngle( P2, 0, 25 )
  pc.setPTStartOffsets( P2, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P2, 1000 )
  pc.setPTBounce( P2, 0, 0, 0 )
  pc.setPTAddedBlend( P2, 0 )

  'TODO Emitter_SetSound EM,soundPath$+"water.mp3",1
  EM.addParticleType( P1, 0, 9000, 100 )
  EM.addParticleType( P2, 0, 9000, 50 )

  Return EM
End Function


Function CreateEmitter_Waterfall:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int, P3:Int

  EM = pc.createEmitter()

  ' MIST
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 2 )
  pc.setPTSpeed( P1, 4, 2 )
  pc.setPTSize( P1, 0.75, 0.75, 4, 4 )
  pc.setPTAlpha( P1, 1, 0.5, -1 )
  pc.setPTWeight( P1, 3, 2 )
  pc.setPTRotation( P1, 0, 90 )
  pc.setPTColor( P1, 225, 225, 250, 40, -125, -125, -100 )
  pc.setPTEmissionAngle( P1, 0, 15 )
  pc.setPTStartOffsets( P1, -3, 6, 0, -1, 0, 0 )
  pc.setPTLifeTime( P1, 3000 )
  pc.setPTBounce( P1, -12, 0, 0 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )

  ' CLOUDS
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 9 )
  pc.setPTSpeed( P2, 2, 2 )
  pc.setPTSize( P2, 0.75, 0.75, 5, 3 )
  pc.setPTAlpha( P2, 0.5, 0.5, -1.5 )
  pc.setPTWeight( P2, 0, 2 )
  pc.setPTRotation( P2, 1, 45 )
  pc.setPTColor( P2, 225, 225, 250, 40, -100, -100, -75 )
  pc.setPTEmissionAngle( P2, 0, 15 )
  pc.setPTStartOffsets( P2, -3, 6, -10.5, 0, 0, 0 )
  pc.setPTLifeTime( P2, 1000 )
  pc.setPTBounce( P2, 0, 0, 0 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )

  ' BUBBLES
  P3 = pc.createParticleType()
  pc.setPTImage( P3, 3 )
  pc.setPTSpeed( P3, 2.5, 2 )
  pc.setPTSize( P3, 0.7, 0.5 )
  pc.setPTAlpha( P3, 1, 0.5, -1 )
  pc.setPTWeight( P3, 0.5, 0.5 )
  pc.setPTRotation( P3, 1, 45 )
  pc.setPTColor( P3, 210, 210, 250, 20, -100, -100, -75 )
  pc.setPTEmissionAngle( P3, 0, 15 )
  pc.setPTStartOffsets( P3, -3, 6, 1, 0, 0, 0 )
  pc.setPTLifeTime( P3, 1000 )
  pc.setPTBounce( P3, 0, 0, 0 )
  pc.setPTPulsation( P3, 0 )
  pc.setPTAddedBlend( P3, 0 )

  'TODO Emitter_SetSound EM,soundPath$+"water.mp3",1
  EM.addParticleType( P1, 0, 9000, 115 )
  EM.addParticleType( P2, 1000, 8000, 40 )
  EM.addParticleType( P3, 0, 9000, 50 )

  Return EM
End Function


Function CreateEmitter_FlameThrower:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int, P3:Int

  EM = pc.createEmitter()

  ' SMOKE
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 5 )
  pc.setPTSpeed( P1, 15, 5 )
  pc.setPTSize( P1, 2, 1, 5, 6 )
  pc.setPTAlpha( P1, 0.7, 0.4, -1 )
  pc.setPTWeight( P1, -0.7, 0.5 )
  pc.setPTRotation( P1, 1, 90 )
  pc.setPTColor( P1, 155, 155, 180, 60, -100, -100, -105 )
  pc.setPTEmissionAngle( P1, 0, 30 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 1500 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )
  ' FLAME
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 5 )
  pc.setPTSpeed( P2, 24, 5 )
  pc.setPTSize( P2, 1, 1, 4, 4 )
  pc.setPTAlpha( P2, 1, 0.5, -1 )
  pc.setPTWeight( P2, -4, 2 )
  pc.setPTRotation( P2, 1, 45 )
  pc.setPTColor( P2, 250, 250, 200, 40, -150, -300, -400 )
  pc.setPTEmissionAngle( P2, 0, 15 )
  pc.setPTStartOffsets( P2, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P2, 1000 )
  pc.setPTBounce( P2, 0, 0, 0 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )
  ' SPARKS
  P3 = pc.createParticleType()
  pc.setPTImage( P3, 1 )
  pc.setPTSpeed( P3, 15, 5 )
  pc.setPTSize( P3, 0.2, 0.2, -1 )
  pc.setPTAlpha( P3, 1, 0.5, -1 )
  pc.setPTWeight( P3, 3, 1 )
  pc.setPTRotation( P3, 2, 90 )
  pc.setPTColor( P3, 250, 100, 0, 50, -100, -100, 0 )
  pc.setPTEmissionAngle( P3, 0, 360 )
  pc.setPTStartOffsets( P3, 0, 0, -0.5, 0, 0, 0 )
  pc.setPTLifeTime( P3, 1000 )
  pc.setPTBounce( P3, 0, 0.7, 10 )
  pc.setPTPulsation( P3, 0 )
  pc.setPTAddedBlend( P3, 1 )

  'TODO Emitter_SetSound EM,soundPath$+"flamethrower.mp3",1
  EM.addParticleType( P1, 0, 9000, 15 )
  EM.addParticleType( P2, 1000, 8000, 35 )
  EM.addParticleType( P3, 0, 1000, 150 )

  Return EM
End Function


Function CreateEmitter_Sparks:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int, P3:Int

  EM = pc.createEmitter()

  ' SMOKE
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 5 )
  pc.setPTSpeed( P1, 5, 2 )
  pc.setPTSize( P1, 1, 1, 2, 3 )
  pc.setPTAlpha( P1, 0.4, 0.4, -1 )
  pc.setPTWeight( P1, -1, 0.5 )
  pc.setPTRotation( P1, 1, 90 )
  pc.setPTColor( P1, 155, 155, 180, 60, -100, -100, -105 )
  pc.setPTEmissionAngle( P1, 0, 30 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 1500 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )
  ' SPARKS
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 1 )
  pc.setPTSpeed( P2, 8, 5 )
  pc.setPTSize( P2, 0.15, 0.5, -1 )
  pc.setPTAlpha( P2, 1, 0.5, -0.5 )
  pc.setPTWeight( P2, 3, 2 )
  pc.setPTRotation( P2, 2, 90 )
  pc.setPTColor( P2, 200, 200, 250, 50, -100, -100, 0 )
  pc.setPTEmissionAngle( P2, 0, 360 )
  pc.setPTStartOffsets( P2, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P2, 2000 )
  pc.setPTBounce( P2, -8, 0.4, 3 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )
  ' FLAME
  P3 = pc.createParticleType()
  pc.setPTImage( P3, 7 )
  pc.setPTSpeed( P3, 0.1, 0 )
  pc.setPTSize( P3, 0.5, 0.5, -0.25 )
  pc.setPTAlpha( P3, 1, 0.5, -0.5 )
  pc.setPTWeight( P3, 0, 2 )
  pc.setPTRotation( P3, 1, 0 )
  pc.setPTColor( P3, 200, 200, 250, 40, -100, -100, 0 )
  pc.setPTEmissionAngle( P3, 0, 360 )
  pc.setPTStartOffsets( P3, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P3, 1000 )
  pc.setPTBounce( P3, 0, 0, 0 )
  pc.setPTPulsation( P3, 3 )
  pc.setPTAddedBlend( P3, 1 )

  'TODO Emitter_SetSound EM,soundPath$+"lightning.mp3",1
  EM.addParticleType( P1, 0, 5000, 15 )
  EM.addParticleType( P2, 0, 5000, 450 )
  EM.addParticleType( P3, 0, 5000, 10 )

  Return EM
End Function


Function CreateEmitter_Torch:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int, P3:Int

  EM = pc.createEmitter()

  ' SMOKE
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 5 )
  pc.setPTSpeed( P1, 5, 2 )
  pc.setPTSize( P1, 1, 1, 2, 3 )
  pc.setPTAlpha( P1, 0.7, 0.5, -1 )
  pc.setPTWeight( P1, -1, 0.5 )
  pc.setPTRotation( P1, 1, 90 )
  pc.setPTColor( P1, 155, 155, 170, 60, -100, -100, -105 )
  pc.setPTEmissionAngle( P1, 0, 30 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 1500 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )
  ' FLAME
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 9 )
  pc.setPTSpeed( P2, 5, 2 )
  pc.setPTSize( P2, 1, 1, 2, 3 )
  pc.setPTAlpha( P2, 0.7, 0.5, -2 )
  pc.setPTWeight( P2, -2, 0.5 )
  pc.setPTRotation( P2, 0, 90 )
  pc.setPTColor( P2, 250, 150, 50, 50, -50, -50, -55 )
  pc.setPTEmissionAngle( P2, 0, 75 )
  pc.setPTStartOffsets( P2, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P2, 1500 )
  pc.setPTBounce( P2, 0, 0, 0 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )
  ' SPARKS
  P3 = pc.createParticleType()
  pc.setPTImage( P3, 1 )
  pc.setPTSpeed( P3, 8, 5 )
  pc.setPTSize( P3, 0.2, 0.2, -0.5 )
  pc.setPTAlpha( P3, 1, 0.5, -1 )
  pc.setPTWeight( P3, 3, 1 )
  pc.setPTRotation( P3, 2, 90 )
  pc.setPTColor( P3, 250, 100, 0, 50, -100, -100, 0 )
  pc.setPTEmissionAngle( P3, 0, 360 )
  pc.setPTStartOffsets( P3, 0, 0, -0.5, 0, 0, 0 )
  pc.setPTLifeTime( P3, 1000 )
  pc.setPTBounce( P3, 0, 0.7, 10 )
  pc.setPTPulsation( P3, 0 )
  pc.setPTAddedBlend( P3, 1 )

  'TODO Emitter_SetSound EM,soundPath$+"flames.mp3",1
  EM.addParticleType( P1, 0, 9000, 50 )
  EM.addParticleType( P2, 0, 9000, 50 )
  EM.addParticleType( P3, 0, 9000, 45 )

  Return EM
End Function


Function CreateEmitter_Smoke:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int

  EM = pc.createEmitter()

  ' SMOKE
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 5 )
  pc.setPTSpeed( P1, 5, 2 )
  pc.setPTSize( P1, 1, 1, 2, 3 )
  pc.setPTAlpha( P1, 0.7, 0.5, -0.8 )
  pc.setPTWeight( P1, -1, 0.5 )
  pc.setPTRotation( P1, 1, 90 )
  pc.setPTColor( P1, 125, 125, 140, 60, -50, -50, -55 )
  pc.setPTEmissionAngle( P1, 0, 75 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 1500 )
  pc.setPTBounce( P1, -5, 1, 10 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )

  'TODO Emitter_SetSound EM,soundPath$+"smoke.mp3",1
  EM.addParticleType( P1, 0, 5000, 75 )

  Return EM
End Function


Function CreateEmitter_Rocks:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int

  EM = pc.createEmitter()

  ' ROCKS
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 8 )
  pc.setPTSpeed( P1, 20, 5 )
  pc.setPTSize( P1, 0.6, 0.5 )
  pc.setPTAlpha( P1, 1, 0, 0 )
  pc.setPTWeight( P1, 8, 5 )
  pc.setPTRotation( P1, 1, 400 )
  pc.setPTColor( P1, 240, 240, 240, 40, 0, 0, 0 )
  pc.setPTEmissionAngle( P1, 3, 130 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 3000 )
  pc.setPTBounce( P1, -7, 0.5, 16 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )
  ' SMOKE
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 5 )
  pc.setPTSpeed( P2, 4, 2 )
  pc.setPTSize( P2, 1, 1, 5 )
  pc.setPTAlpha( P2, 0.5, 0.3, -1 )
  pc.setPTWeight( P2, -0.5, 0.1 )
  pc.setPTRotation( P2, 1, 45 )
  pc.setPTColor( P2, 125, 125, 130, 20, -15, -15, -25 )
  pc.setPTEmissionAngle( P2, 3, 180 )
  pc.setPTStartOffsets( P2, -3, 6, -2, 8, -3, 6 )
  pc.setPTLifeTime( P2, 1000 )
  pc.setPTBounce( P2, -5, 1, 10 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 0 )

  'TODO Emitter_SetSound EM,soundPath$+"bang.mp3",0
  EM.addParticleType( P1, 0, 50, 400 )
  EM.addParticleType( P2, 0, 50, 200 )

  Return EM
End Function


Function CreateEmitter_SmokeFlares:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int

  EM = pc.createEmitter()

  ' SMOKE TRAIL
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 9 )
  pc.setPTSpeed( P1, 4, 2 )
  pc.setPTSize( P1, 0.5, 0.5, 3, 1 )
  pc.setPTAlpha( P1, 0.25, 0.25, -0.45 )
  pc.setPTWeight( P1, -0.5, 0.1 )
  pc.setPTRotation( P1, 1, 45 )
  pc.setPTColor( P1, 125, 125, 135, 20, -15, -15, -25 )
  pc.setPTEmissionAngle( P1, 3, 180 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 3000 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTPulsation( P1, 0 )
  pc.setPTAddedBlend( P1, 0 )
  ' ROCKS
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 7 )
  pc.setPTSpeed( P2, 20, 5 )
  pc.setPTSize( P2, 0.6, 0.5 )
  pc.setPTAlpha( P2, 1, 0, 0 )
  pc.setPTWeight( P2, 8, 5 )
  pc.setPTRotation( P2, 1, 400 )
  pc.setPTColor( P2, 200, 180, 160, 40, 0, -50, -50 )
  pc.setPTEmissionAngle( P2, 3, 130 )
  pc.setPTStartOffsets( P2, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P2, 3000 )
  pc.setPTBounce( P2, -7, 0.5, 16 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )
  pc.setPTTrail( P2, P1, 0, 3000, 45 )

  'TODO Emitter_SetSound EM,soundPath$+"bang.mp3",0
  EM.addParticleType( P2, 0, 50, 400 )

  Return EM
End Function


' EXPLOSION
Function CreateEmitter_Explosion1:Emitter( pc:ParticleCandy )
  Local EM:Emitter, P1:Int, P2:Int, P3:Int, P4:Int, P5:Int

  EM = pc.createEmitter()

  ' SHORT FLASH
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 5 )
  pc.setPTSpeed( P1, 0, 0 )
  pc.setPTSize( P1, 2, 0, -2 )
  pc.setPTAlpha( P1, 1, 0, 0 )
  pc.setPTWeight( P1, 0, 0 )
  pc.setPTRotation( P1, 1, 0 )
  pc.setPTColor( P1, 255, 255, 200, 0, -200, -200, -200 )
  pc.setPTEmissionAngle( P1, 0, 1 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 500 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTPulsation( P1, 4 )
  pc.setPTAddedBlend( P1, 1 )
  ' RED CLOUDS
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 5 )
  pc.setPTSpeed( P2, 0, 0 )
  pc.setPTSize( P2, 1, 0.5, 15, 5 )
  pc.setPTAlpha( P2, 1, 0.25, -0.18 )
  pc.setPTWeight( P2, 0, 0 )
  pc.setPTRotation( P2, 1, 0 )
  pc.setPTColor( P2, 255, 246, 149, 0, -150, -200, -200 )
  pc.setPTEmissionAngle( P2, 0, 360 )
  pc.setPTStartOffsets( P2, -3, 6, -3, 6, -3, 6 )
  pc.setPTLifeTime( P2, 2000 )
  pc.setPTBounce( P2, 0, 0, 0 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )
  ' SMALL PARTICLES
  P3 = pc.createParticleType()
  pc.setPTImage( P3, 6 )
  pc.setPTSpeed( P3, 10, 1 )
  pc.setPTSize( P3, 3, 0.5, -1 )
  pc.setPTAlpha( P3, 1, 0.25, -0.8 )
  pc.setPTWeight( P3, 0, 0 )
  pc.setPTRotation( P3, 1, 0 )
  pc.setPTColor( P3, 255, 246, 149, 0, 0, 0, 0 )
  pc.setPTEmissionAngle( P3, 0, 360 )
  pc.setPTStartOffsets( P3, -1, 2, -1, 2, -1, 2 )
  pc.setPTLifeTime( P3, 2000 )
  pc.setPTBounce( P3, 0, 0, 0 )
  pc.setPTPulsation( P3, 0 )
  pc.setPTAddedBlend( P3, 1 )
  ' SMOKE
  P4 = pc.createParticleType()
  pc.setPTImage( P4, 5 )
  pc.setPTSpeed( P4, 2, 0.5 )
  pc.setPTSize( P4, 1, 0.5, 15, 4 )
  pc.setPTAlpha( P4, 1, 0.25, -0.15 )
  pc.setPTWeight( P4, 0, 0 )
  pc.setPTRotation( P4, 1, 0 )
  pc.setPTColor( P4, 70, 70, 70, 20, -30, -30, -30 )
  pc.setPTEmissionAngle( P4, 0, 360 )
  pc.setPTStartOffsets( P4, -4, 8, -4, 8, -4, 8 )
  pc.setPTLifeTime( P4, 3000 )
  pc.setPTBounce( P4, 0, 0, 0 )
  pc.setPTPulsation( P4, 0 )
  pc.setPTAddedBlend( P4, 1 )
  ' SPARKS
  P5 = pc.createParticleType()
  pc.setPTImage( P5, 1 )
  pc.setPTSpeed( P5, 15, 5 )
  pc.setPTSize( P5, 0.5, 0.15, -0.5 )
  pc.setPTAlpha( P5, 1, 0.25, -0.18 )
  pc.setPTWeight( P5, 2, 0 )
  pc.setPTRotation( P5, 2, 0 )
  pc.setPTColor( P5, 255, 246, 149, 20, -150, -200, -150 )
  pc.setPTEmissionAngle( P5, 0, 360 )
  pc.setPTStartOffsets( P5, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P5, 2000 )
  pc.setPTBounce( P5, 0, 0, 0 )
  pc.setPTPulsation( P5, 0 )
  pc.setPTAddedBlend( P5, 1 )

  'TODO Emitter_SetSound EM,soundPath$+"explosion.mp3",0
  EM.addParticleType( P1, 0, 110, 10 )
  EM.addParticleType( P2, 100, 150, 50 )
  EM.addParticleType( P3, 150, 200, 125 )
  EM.addParticleType( P4, 250, 350, 40 )
  EM.addParticleType( P5, 100, 400, 150 )

  Return EM	
End Function


' EXPLOSION 2
Function CreateEmitter_Explosion2:Emitter( pc:ParticleCandy )
Local EM:Emitter, P1:Int, P2:Int, P3:Int, P4:Int, P5:Int, P6:Int, P7:Int

  EM = pc.createEmitter()

  ' SHORT FLASH
  P1 = pc.createParticleType()
  pc.setPTImage( P1, 5 )
  pc.setPTSpeed( P1, 0, 0 )
  pc.setPTSize( P1, 2, 0, -2 )
  pc.setPTAlpha( P1, 1, 0, 0 )
  pc.setPTWeight( P1, 0, 0 )
  pc.setPTRotation( P1, 1, 0 )
  pc.setPTColor( P1, 255, 255, 200, 0, -200, -200, -200 )
  pc.setPTEmissionAngle( P1, 0, 1 )
  pc.setPTStartOffsets( P1, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P1, 500 )
  pc.setPTBounce( P1, 0, 0, 0 )
  pc.setPTPulsation( P1, 4 )
  pc.setPTAddedBlend( P1, 1 )
  ' RED CLOUDS
  P2 = pc.createParticleType()
  pc.setPTImage( P2, 5 )
  pc.setPTSpeed( P2, 0, 0 )
  pc.setPTSize( P2, 1, 0.5, 15, 5 )
  pc.setPTAlpha( P2, 1, 0.25, -0.18 )
  pc.setPTWeight( P2, 0, 0 )
  pc.setPTRotation( P2, 1, 0 )
  pc.setPTColor( P2, 255, 246, 149, 0, -150, -200, -200 )
  pc.setPTEmissionAngle( P2, 0, 360 )
  pc.setPTStartOffsets( P2, -3, 6, -3, 6, -3, 6 )
  pc.setPTLifeTime( P2, 2000 )
  pc.setPTBounce( P2, 0, 0, 0 )
  pc.setPTPulsation( P2, 0 )
  pc.setPTAddedBlend( P2, 1 )
  ' SPARKS
  P3 = pc.createParticleType()
  pc.setPTImage( P3, 1 )
  pc.setPTSpeed( P3, 20, 5 )
  pc.setPTSize( P3, 0.5, 0.5, -1 )
  pc.setPTAlpha( P3, 1, 0.25, -0.8 )
  pc.setPTWeight( P3, 0, 0 )
  pc.setPTRotation( P3, 2, 0 )
  pc.setPTColor( P3, 255, 246, 149, 50, -200, -300, -300 )
  pc.setPTEmissionAngle( P3, 0, 360 )
  pc.setPTStartOffsets( P3, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P3, 2000 )
  pc.setPTBounce( P3, 0, 0, 0 )
  pc.setPTPulsation( P3, 0 )
  pc.setPTAddedBlend( P3, 1 )
  ' SMOKE
  P4 = pc.createParticleType()
  pc.setPTImage( P4, 5 )
  pc.setPTSpeed( P4, 2, 0.5 )
  pc.setPTSize( P4, 1, 0.5, 15, 4 )
  pc.setPTAlpha( P4, 1, 0.25, -0.15 )
  pc.setPTWeight( P4, 0, 0 )
  pc.setPTRotation( P4, 1, 0 )
  pc.setPTColor( P4, 70, 70, 70, 20, -30, -30, -30 )
  pc.setPTEmissionAngle( P4, 0, 360 )
  pc.setPTStartOffsets( P4, -4, 8, -4, 8, -4, 8 )
  pc.setPTLifeTime( P4, 3000 )
  pc.setPTBounce( P4, 0, 0, 0 )
  pc.setPTPulsation( P4, 0 )
  pc.setPTAddedBlend( P4, 1 )
  ' DEBRIS SMOKE TRAIL
  P5 = pc.createParticleType()
  pc.setPTImage( P5, 9 )
  pc.setPTSpeed( P5, 4, 2 )
  pc.setPTSize( P5, 0.5, 0.5, 3, 1 )
  pc.setPTAlpha( P5, 0.25, 0.25, -0.45 )
  pc.setPTWeight( P5, 0, 0.1 )
  pc.setPTRotation( P5, 1, 45 )
  pc.setPTColor( P5, 125, 125, 135, 20, -15, -15, -25 )
  pc.setPTEmissionAngle( P5, 3, 180 )
  pc.setPTStartOffsets( P5, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P5, 3000 )
  pc.setPTBounce( P5, 0, 0, 0 )
  pc.setPTPulsation( P5, 0 )
  pc.setPTAddedBlend( P5, 0 )
  ' DEBRIS
  P6 = pc.createParticleType()
  pc.setPTImage( P6, 7 )
  pc.setPTSpeed( P6, 15, 5 )
  pc.setPTSize( P6, 1, 0.5, -1 )
  pc.setPTAlpha( P6, 1, 0.25, -0.15 )
  pc.setPTWeight( P6, 1, 0 )
  pc.setPTRotation( P6, 0, 0 )
  pc.setPTColor( P6, 255, 246, 149, 20, -150, -200, -150 )
  pc.setPTEmissionAngle( P6, 3, 360 )
  pc.setPTStartOffsets( P6, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P6, 2000 )
  pc.setPTBounce( P6, 0, 0, 0 )
  pc.setPTPulsation( P6, 0 )
  pc.setPTAddedBlend( P6, 1 )
  pc.setPTTrail( P6, P5, 0, 1000, 45 )
  ' SPARKLES
  P7 = pc.createParticleType()
  pc.setPTImage( P7, 7 )
  pc.setPTSpeed( P7, 1, 0.5)
  pc.setPTRandomSpeed( P7, 0.05, 0.05, 0.05 )
  pc.setPTSize( P7, 0.5, 0.5, -0.5 )
  pc.setPTAlpha( P7, 1, 0.25, -0.15 )
  pc.setPTWeight( P7, 1, 0 )
  pc.setPTRotation( P7, 0, 0 )
  pc.setPTColor( P7, 255, 246, 149, 20, -150, -200, -150 )
  pc.setPTEmissionAngle( P7, 3, 360 )
  pc.setPTStartOffsets( P7, 0, 0, 0, 0, 0, 0 )
  pc.setPTLifeTime( P7, 2000 )
  pc.setPTBounce( P7, 0, 0, 0 )
  pc.setPTPulsation( P7, 0 )
  pc.setPTAddedBlend( P7, 1 )

  'TODO Emitter_SetSound EM,soundPath$+"explosion.mp3",0
  EM.addParticleType( P1, 0, 110, 10 )
  EM.addParticleType( P2, 100, 150, 50 )
  EM.addParticleType( P3, 200, 250, 150 )
  EM.addParticleType( P4, 250, 350, 40 )
  EM.addParticleType( P6, 100, 300, 125 )
  EM.addParticleType( P7, 400, 600, 150 )

  Return EM	
End Function
